Skip to main content

Read from Blockchain

Reading from the blockchain is done using Unity-Native implementation of our Sequence Indexer. We recommend creating an instance of the ChainIndexer class. This will expose you to all the functionality offered by the IIndexer interface.
You can check if the indexer API for your given chain is up and running using the Ping async Task. This can be useful if a request is failing. During development, you can also check the status of our indexers on our status page.

Get Balance

To check the Ether (or whatever your network’s default gas currency is) balance of a user, use the GetEtherBalance async Task.

Get Token Balances

To fetch the token balances for a user you’ll want to use the GetTokenBalances async Task.
When fetched this way, you will only receive one token instance for each smart contract. Fetching, without specifying the address, is useful to determine which contracts your player owns tokens from and which ERC20s they have in their wallet. To fetch individual balances for ERC721 or ERC1155 tokens, you’ll want to specify the contract in your GetTokenBalancesArgs.
If the player has many tokenIds for a given contract (or owns tokens from many contracts), you’ll have to deal with pagination. In this case, you’ll want to check the Page you receive in your GetTokenBalancesReturn to see if it has more and then if it does make another request, including the Page.
To simplify this operation, we’ve created a wrapper GetTokenBalancesOrganizedInDictionary. This will fetch all of the TokenBalances for a given contractAddress and userAccountAddress and organize them into a Dictionary mapping tokenID (BigInteger) to TokenBalance. In general, you’ll want to use this most often.
This will make checking the respective balance for each token id much easier as well.

Get Token Supplies

If you need to fetch the total token supply for a given smart contract, you can use the GetTokenSupplies async Task.
We don’t expect this to be a very common operation, but it is exposed for you just in case you need it.

Get Token Supplies Map

For GetTokenSupplies power users, we also provide a GetTokenSuppliesMap async Task that allows you to fetch the supplies for multiple token contracts and token ids in a map.
Here, you can expect that suppliesMap[usdcAddress].Length = 1 with the TokenSupply object relating to the supply of the ERC20 token. Similarly, you can expect that suppliesMap[skyweaverAddress].Length = 3 with the TokenSupply object relating to the specified token ids.

Get Transaction history

To fetch the transaction history for a given account, you’ll want to use the GetTransactionHistory method.
The TransactionHistoryFilter object allows you to specify how you want to filter your transaction history query, e.g. by account address(es), contract address(es), etc. More info here.